<?php

namespace App\Jobs\Plane;

use App\Models\Plane\Comfort\PlaneComfort;
use App\Trip\Plane\Variflight\Result\QueryResultFlight;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class ProcessComfortData implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public int                $retry = 1;
    private QueryResultFlight $flight;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(QueryResultFlight $flight)
    {
        $this->flight = $flight;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $comfort = new PlaneComfort();
        $comfort->add($this->flight->getFlightInfo());
    }

    /**
     * 任务的唯一 ID。
     *
     * @return
     */
    public function uniqueId()
    {
        return "ProcessComfortData:".$this->flight->getFlightNo();
    }
}
